#ifndef SEQIOT_PACKET_H
#define SEQIOT_PACKET_H

#include <stdint.h>

//自定义数据包格式
typedef struct _datetime_t {
    int sec: 6;
    int min: 6;
    int hour: 5;
    int day: 5;
    int mon: 4;
    int year: 6;
}__attribute__ ((packed)) datetime_t;

//flag_bits = 7{has_quality}6{has_timestamp}5{float/double}4{signed}3210{value_len}
typedef struct _tag_header_t {
    uint16_t tag_id;
    uint8_t value_len: 4;//值紧跟head
    _Bool is_signed: 1;//是否为有符号数
    _Bool is_floating: 1;
    _Bool has_timestamp: 1;//时间戳是在value后面
    _Bool has_quality: 1;
    uint8_t quality;
}__attribute__ ((packed)) tag_header_t;

typedef struct _hdb_header_t {
    uint16_t dev_id;
    uint16_t n_tags;
}__attribute__ ((packed)) hdb_header_t;

#endif //SEQIOT_PACKET_H
